package com.yaorange.common.enums;

public enum SysRoleEnum {
    ADMIN("管理员", "admin"),
    REGULATOR("监管者", "regulator"),
    COMMON("普通⻆⾊", "common"),
    ;
    final String roleName;
    final String roleCode;
    SysRoleEnum(String roleName, String roleCode) {
        this.roleName = roleName;
        this.roleCode = roleCode;
    }
    public String getRoleName() {
        return roleName;
    }
    public String getRoleCode() {
        return roleCode;
    }
    /**
     * 匹配枚举值
     *
     * @param roleCode ⻆⾊编码
     * @return SysRoleEnum
     */
    public static SysRoleEnum of(String roleCode) {
        if (roleCode == null) {
            return null;
        }
        SysRoleEnum[] values = SysRoleEnum.values();
        for (SysRoleEnum roleEnum : values) {
            if (roleEnum.roleCode.equals(roleCode)) {
                return roleEnum;
            }
        }
        return null;
    }
/**
 * 通过⻆⾊编码获取⻆⾊名称
 *
 * @param roleCode ⻆⾊编码
 * @return roleName
 */
public static String getByRoleCode(String roleCode) {
    SysRoleEnum sysRoleEnum = of(roleCode);
    if (null != sysRoleEnum) {
        return sysRoleEnum.roleName;
    }
    return "";
}
}